//
//  Observer.m
//  观察者模式
//
//  Created by flannery on 2018/12/19.
//  Copyright © 2018年 flannery. All rights reserved.
//

#import "Observer.h"
#import "Subject.h"

@implementation Observer
- (void)update{}
@end


@implementation BinaryObserver
- (instancetype)initWithSubject:(Subject *)subject{
    if(self = [super init]) {
        super.subject = subject;
        [super.subject attach:self];
    }
    return self;
}
- (void)update{
    NSLog(@"BinaryObserver String: %d", self.subject.state);
}
@end


@implementation OctalObserver
- (instancetype)initWithSubject:(Subject *)subject{
    if(self = [super init]) {
        super.subject = subject;
        [super.subject attach:self];
    }
    return self;
}

- (void)update{
    NSLog(@"OctalObserver String: %d", self.subject.state);
}
@end


@implementation HexaObserver

- (instancetype)initWithSubject:(Subject *)subject{
    if(self = [super init]) {
        super.subject = subject;
        [super.subject attach:self];
    }
    return self;
}

- (void)update{
    NSLog(@"HexaObserver String: %d", self.subject.state);
}
@end
